<template lang="html">

<div class="page has-footer">
  <cube-scroll  :options="{scrollbar:{fade: true}}">
    <div class="top-slides">
      <cube-slide ref="slide" :data="Slides" @change="changeSlide" class="top-slides">
        <cube-slide-item v-for="(item, index) in Slides" :key="index" @click.native="clickHandler(item, index)">
          <a :href="item.LinkUrl" :style="{backgroundImage: 'url('+ item.CoverImage +')'}"> <img :src="item.CoverImage"> </a>
        </cube-slide-item>
      </cube-slide>
    </div>
    <tit has-bg more-link="/more" has-line>调度公开</tit>
    <list :is-empty="!pubList.length">
      <item :img-src="item.CoverImage"
      v-for="(item,index) in pubList" :key="index"
      :title="item.Title"
      :desc="item.Summary"
      :href="'/home/detail/' + item.Id"
      >
        <div class="text-footer" slot="text-footer">所属单位：{{item.DeptName}}</div>
        <div class="label" slot="label"> 已完成 </div>
      </item>
    </list>
    <tit has-bg more-link="/my/wddb" right-text="更多" has-line class="mt-md">我的待办</tit>
    <list :is-empty="!todoList.length">
      <item :img-src="item.CoverImage"
        v-for="(item,index) in todoList" :key="index"
        :title="item.Title"
        :desc="item.Summary"
        :href="'/home/detail/' + item.Id"
        >
        <div class="text-footer" slot="text-footer">所属单位：{{item.DeptName}}</div>
        <div class="label" slot="label"> 待处理 </div>
      </item>
    </list>

  </cube-scroll>

</div>
</template>

<script>
export default {

  data() {
    return {
      List: [],
      pubList:[],
      todoList:[],
      Slides: [
    {
    "Title":"人工智能将取代人类",
    "LinkUrl" : "/",
    "CoverImage":"http://oz3n01eow.bkt.clouddn.com/i1.jpg"
    },
    {
    "Title":"IT行业的春天来了",
    "CoverImage":"http://oz3n01eow.bkt.clouddn.com/i2.jpg"
    },
    {
    "Title":"Google宣布收购苹果",
    "CoverImage":"http://oz3n01eow.bkt.clouddn.com/t7.jpg"
    },
    {
    "Title":"Google宣布收购苹果",
    "CoverImage":"http://oz3n01eow.bkt.clouddn.com/t10.jpg"
    }
  ],
    }
  },
  created () {
    //this.getListData();
    this.getPublicList();
    this.getTodoList();
  },
  methods : {
    getPublicList() {
      this.$http.post("app/Handler/DispatchHandler.ashx?action=GetTopPublicList")
      .then(data => {
        console.log(data);
        if(data.code == 0){
          this.pubList = data.data;
        }
      })	 
    },
    getTodoList() {
      this.$http.post("app/Handler/DispatchHandler.ashx?action=GetTopTodoList")
      .then(data => {
        console.log(data);
        if(data.code == 0){
          this.todoList = data.data;
        }
      })	 
    },
    getListData() {
      this.axios.get('https://jason588.github.io/data.json').then((res) => {
        this.List = res.data.List
        this.Slides = res.data.slides
      })
    },
    changeSlide(current) {
      console.log('当前轮播图序号为:' + current)
    },
    clickHandler(item, index) {
      console.log(item, index)
    }
  },
}
</script>

<style lang="stylus">
@import "assets/stylus/base"
</style>
